import sublime, sublime_plugin

class LiuxiboCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        if len(self.view.window().folders())>0:
            #print self.view.window().folders()[0]
            #print self.view.window().folders()[0].split("/")[-1]
            if len(self.view.file_name()) > 0:
                str_path=self.view.file_name().split(self.view.window().folders()[0])[-1]
                print self.view.file_name()
                print str_path
                sublime.set_clipboard(str_path)
                sublime.status_message("Copied relative file path")
        else:
            if len(self.view.file_name()) > 0:
                sublime.set_clipboard(self.view.file_name())
                sublime.status_message("Copied absolute file path")

    def is_enabled(self):
        return self.view.file_name() and len(self.view.file_name()) > 0
